<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"  lang="en">
<head>
    <link rel="stylesheet" type="text/css" th:href="@{/static/layui-v2.6.13/layui/css/layui.css}"/>
    <script type="text/javascript" th:src="@{/static/layui-v2.6.13/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/jquery-1.9.1.min.js}"></script>
    <meta charset="utf-8">
    <title>更新页</title>
    <script>
        layui.use('upload',function(){
            var upload = layui.upload;
            upload.render({
                elem:'#imgUpload'
                ,url:'upload'
                ,accept:'images'
                ,acceptMime:'image/*'
                ,done:function(res){
                $("#imgUrl").val(res.imgUrl);
                }
            });
        }
        );
    </script>
</head>
<body>
<div style="width: 100%; margin: 0 auto;">
    <form class="layui-form">
        <input type="hidden" name="id" th:value="${good.id}">
        <table class="layui-table" lay-skin="nob">
            <tr>
                <td><input type="text" name="name" class="layui-input"  th:value="${good.name}"></td>
                <td>
                    <button type="button" class="layui-btn" id="imgUpload">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                    <input type="hidden" name="url" id="imgUrl" th:value="${good.url}">
                </td>
            </tr>
            <tr>
                <td><input type="text" name="amount" class="layui-input" th:value="${good.amount}"></td>
                <td><input type="text" name="price" class="layui-input" th:value="${good.price}"></td>
            </tr>
            <tr>
                <td>
                    <select name="type">
                        <option value="" >商品类别</option>
                        <option th:each="types:${typelist}" th:value="${types.type}" th:text="${types.name}"
                                th:selected="${types.type eq good.type}"></option>
                    </select>
                </td>
                <td>
                    <select>
                        <option value="">商品状态</option>
                        <option value="0" th:selected="${good.sale eq 0}">下架</option>
                        <option value="1" th:selected="${good.sale eq 1}">上架</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <button class="layui-btn layui-btn-fluid" onclick="upd()">保存</button>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script>
	layui.use('layer',function(){
		var layer = layui.layer;
	});
	function upd(){
		var form = $("form").serialize();
		$.ajax({
			url:'update',
			type:'post',
			data:form,
			success:function(obj){
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			}
		});
	}
</script>
</html>

















